<?php
define('IN_QY',true);
require("include/common.inc.php");
//模板api
$serh=$_POST['huan'];


$reslut = "select count(*) as a from ap_muban where 1=1 ";		

$query_reslut = mysql_query($reslut);
$row_reslut=mysql_fetch_array($query_reslut);
$count=$row_reslut['a'];
//页面数量
$page_size=5;
//总页数
$page_count = ceil($count/$page_size);

//第几页
$page=$_POST['page'];
if($page==''){
  $page=1;
}
$last=$page-1;//上一页
$next=$page+1;//下一页

if($page>$page_count){

    $arr = 0;
    echo $arr;
    exit;

}

//页面起始条数
$offset=$page_size*($page-1);
if($serh==1){
$sql = "select * from ap_muban  where 1=1   order by id desc  limit $offset,$page_size";

}
if($serh==2){
$sql = "select * from ap_muban  where 1=1  order by jqian asc limit $offset,$page_size";
}

$query = mysql_query($sql);

class Stu{  
//app首页商品表，字段解释
    public $id;  
    public $img; 
    public $title;  
    public $price; 
    public $fenlei;
    public $addtime;
} 
while($row=mysql_fetch_object($query)){   
 	
    $s=new Stu();
    $s->id=$row->id;  
    $s->title=$row->title;  
    $s->price=$row->jqian;  
    $s->fenlei=$row->fenlei;   	
    $s->img=$row->img;  
    $s->addtime=$row->time;  	
	$arr[]=$s;
} 
echo json_encode(array('error'=>1,'data'=>$arr)); 

//
